package com.mck.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.jakarta.StatViewServlet;
import com.alibaba.druid.support.jakarta.WebStatFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
import java.sql.SQLException;
import org.springframework.context.annotation.Lazy;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Slf4j
@Configuration
public class DruidConfig {

    @Bean(initMethod = "init")
    @Primary
    @ConfigurationProperties("spring.datasource")
    public DruidDataSource dataSource() {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDbType(com.alibaba.druid.DbType.mysql.name());
        return druidDataSource;
    }
}